package com.zw.stock_sell_storage.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zw.stock_sell_storage.dto.MyPageDto;
import com.zw.stock_sell_storage.dto.RoleDto;
import com.zw.stock_sell_storage.dto.ex.RoleDtoEx;
import com.zw.stock_sell_storage.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/role")
public class RoleController {
    @Autowired
    IRoleService iRoleService;

    @RequestMapping("/queryRoleList")
    public Page<RoleDto> queryRoleList(@RequestBody MyPageDto<RoleDto> myPageDto){
        return iRoleService.queryRoleList(myPageDto);
    }

    @RequestMapping("/queryRoleByUserId")
    public List<RoleDto> queryRoleByUserId(int userId){
        return iRoleService.queryRoleByUserId(userId);
    }

    @RequestMapping("/addRole")
    public boolean addRole(@RequestBody RoleDtoEx roleDtoEx){
        return iRoleService.addRole(roleDtoEx);
    }

    @RequestMapping("/rmvRole")
    public boolean rmvRole(int roleId){
        return iRoleService.rmvRole(roleId);
    }

    @RequestMapping("/queryRoleById")
    public RoleDtoEx queryRoleById(int roleId){
        return iRoleService.queryRoleById(roleId);
    }

    @RequestMapping("/updateRole")
    public boolean updateRole(@RequestBody RoleDtoEx roleDtoEx){
        return iRoleService.updateRole(roleDtoEx);
    }

    @RequestMapping("/queryAllRole")
    public List<RoleDto> queryAllRole(){
        return iRoleService.queryAllRole();
    }

}
